package com.cw.base.common.model.dto.base;

import java.io.Serializable;

import javax.validation.constraints.NotNull;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 公共用户信息请求报文
 *
 * @author chenw
 * @version $$Id: BaseUserReqDto.java, v 0.1 2018/9/19 下午2:41 chenw Exp $$
 */
@Data
@ApiModel(value = "BaseUserReqDto", description = "公共用户请求报文")
public class BaseUserReqDto implements Serializable {

    /** serialVersionUID */
    private static final long serialVersionUID = 782642745245832272L;

    /** 通行证ID */
    @NotNull(message = "通行证ID不能为空")
    @ApiModelProperty(value = "通行证ID")
    private String authId;
    /** token-渠道端的用户认证ID */
    @NotNull(message = "token不能为空")
    @ApiModelProperty(value = "token")
    private String token;
    /** 所属机构id */
    @ApiModelProperty(value = "所属机构id")
    private String organId;
    /** 所属机构名称 */
    @ApiModelProperty(value = "所属机构名称")
    private String organName;
    /** 操作人id */
    @ApiModelProperty(value = "操作人id")
    private String operatorId;
    /** 操作人姓名 */
    @ApiModelProperty(value = "操作人姓名")
    private String operatorName;

    public static final class Builder {

        private BaseUserReqDto instance = new BaseUserReqDto();

        private Builder() {}

        /**
         * 获取实例
         *
         * @return {@link Builder}
         */
        public static Builder getInstance() {
            return new Builder();
        }

        /**
         * 获取实例
         *
         * @param instance 原实例
         * @return {@link Builder}
         */
        public static Builder getInstance(BaseUserReqDto instance) {
            Builder builder = new Builder();
            builder.instance = instance;
            return builder;
        }

        /**
         * 添加参数
         *
         * @param authId 参数
         * @return {@link Builder}
         */
        public Builder addAuthId(String authId) {
            this.instance.setAuthId(authId);
            return this;
        }

        /**
         * 添加参数
         *
         * @param token 参数
         * @return {@link Builder}
         */
        public Builder addToken(String token) {
            this.instance.setToken(token);
            return this;
        }

        /**
         * 添加参数
         *
         * @param operatorId 参数
         * @return {@link Builder}
         */
        public Builder addOperatorId(String operatorId) {
            this.instance.setOperatorId(operatorId);
            return this;
        }

        /**
         * 添加参数
         *
         * @param operatorName 参数
         * @return {@link Builder}
         */
        public Builder addOperatorName(String operatorName) {
            this.instance.setOperatorName(operatorName);
            return this;
        }

        /**
         * 添加参数
         *
         * @param organId 参数
         * @return {@link Builder}
         */
        public Builder addOrganId(String organId) {
            this.instance.setOrganId(organId);
            return this;
        }

        /**
         * 添加参数
         *
         * @param organName 参数
         * @return {@link Builder}
         */
        public Builder addOrganName(String organName) {
            this.instance.setOrganName(organName);
            return this;
        }

        /**
         * 生成实例
         *
         * @return {@link BaseUserReqDto}
         */
        public BaseUserReqDto build() {
            return this.instance;
        }
    }

    /**
     * 相当于深拷贝出一个全新的{@link BaseUserReqDto}对象
     *
     * @return 全新的 {@link BaseUserReqDto}对象
     */
    public BaseUserReqDto copy() {
        return BaseUserReqDto.Builder.getInstance()
            .addOrganName(getOrganName())
            .addOrganId(getOrganId())
            .addOperatorName(getOperatorName())
            .addOperatorId(getOperatorId())
            .addToken(getToken())
            .addAuthId(getAuthId())
            .build();
    }
}
